package bishi.day19_5_16;

import java.util.Scanner;

/**
 * @author 是阿秋啊
 * @date 2022/05/16 21:32
 **/
public class he_qi_shui {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int count = 0;
            while(n >= 2) {
                if (n == 2) {
                    count++;
                    break;
                }
                count += n / 3;
                n = n / 3 + n % 3;
            }
            System.out.println(count);
        }
    }
}